<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:34:"./themes/admin/dp\record_edit.html";i:1741136396;s:43:"D:\wwwroot\dpwkt.com\themes\admin\base.html";i:1576462546;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
<style>
    font{
        color: #cc0000;
    }
</style>

    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!--tab标签-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class=""><a href="<?php echo url('admin/dp/record'); ?>">记录</a></li>
                <li class="layui-this">添加</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" action="<?php echo url('admin/dp/edit_record'); ?>" method="post">
                        <div class="layui-form-item">
                            <label class="layui-form-label">分类</label>
                            <div class="layui-input-block">
                                <select name="type" lay-verify="required" lay-search="">
                                    <?php if(is_array($type_list) || $type_list instanceof \think\Collection || $type_list instanceof \think\Paginator): if( count($type_list)==0 ) : echo "" ;else: foreach($type_list as $key=>$vo): ?>
                                    <option value="<?php echo $vo['id']; ?>" <?php if($vo['id'] == $record['type']): ?>selected<?php endif; ?>><?php echo $vo['name']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" value="<?php echo $record['name']; ?>" required  lay-verify="required" placeholder="请输入名称" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">描述</label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入描述" name="desc" class="layui-textarea"><?php echo $record['desc']; ?></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">图片</label>
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" id="test1">上传图片</button>
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" id="demo1" width="100" height="100" src="/public/<?php echo $record['img']; ?>">
                                    <input type="hidden" name="img" id="img" value="<?php echo $record['img']; ?>">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">视频</label>
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" id="test5"><i class="layui-icon"></i>上传视频</button>
                                <div class="layui-upload-list">
                                    <input type="text" name="video" id="video" value="<?php echo $record['video']; ?>" class="layui-input" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-block">
                                <input type="text" name="sort" value="<?php echo $record['sort']; ?>" required  lay-verify="required" placeholder="请输入排序值(越小越靠前)" class="layui-input">
                            </div>
                        </div>
                        <input type="hidden" name="id" value="<?php echo $record['id']; ?>">
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="*">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
    layui.use(['form','upload'], function(){
        var form = layui.form,upload = layui.upload;

        var uploadInst = upload.render({
            elem: '#test1'
            ,url: '/admin/dp/upload'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                if(res.code == 1){
                    $('#img').val(res.data.url)
                }
                layer.msg(res.msg);
            }
            ,error: function(){
                //演示失败状态，并实现重传
            }
        });

        upload.render({
            elem: '#test5'
            ,url: '/admin/dp/upload' //此处配置你自己的上传接口即可
            ,accept: 'video' //视频
            ,done: function(res){
                if(res.code == 1){
                    $('#video').val(res.data.url)
                }
                layer.msg(res.msg);
            }
        });

        /**
         * 通用表单提交(AJAX方式)
         */
        form.on('submit(*)', function (data) {
            $.ajax({
                url: data.form.action,
                type: data.form.method,
                data: $(data.form).serialize(),
                success: function (info) {
                    if (info.code === 1) {
                        setTimeout(function () {
                            window.location.reload()
                        }, 1000);
                    }
                    layer.msg(info.msg);
                }
            });

            return false;
        });

    });
</script>

<!--页面JS脚本-->
</body>
</html>

